function requestFeed( _feedUrl )
{
	$.post(_feedUrl, {}, feedReceived);
	$("#url").html("RSS URL: <a href=\"" + _feedUrl + "\">" + _feedUrl + "</a>");
}

function feedReceived( _data )
{
	//console.log(_data);
	// clear items
	var itemList = $("#items");
	itemList.empty();
	// generate feed items
	var items = $(_data).find("item");
	for ( var i = 0; i < items.length ; ++i )
	{
		$(itemList).append(generateFeedItemElement(items[i], "item-" + i));
	}
	viewItems();
}

function generateFeedItemElement( _item, _itemId )
{
	var title = $($(_item).find("title")[0]).text();
	var pubDate = $($(_item).find("pubDate")[0]).text();
	var author = $($(_item).find("author")[0]).text();
	var content = $($(_item).find("content")[0]).text();
	var link = $($(_item).find("link")).attr("href");
	return $('<div/>', {  
    id: _itemId,
		class: "feed-item",
   html: "<a href=\"http://" + link + "\">" + title + "</a>: <br>" + pubDate + "<br>" + author + " said - <br><div class='item-content'>\"" + content + "\"</div>"
	});
}